//  n<=3000 m<=3000
#include <bits/stdc++.h>
using namespace std;
int n,m,l,v;
struct Car{
    int x,v,a;
}c[5005];
int a[5005],t[5005]={0},vis[5005]={0};
struct cam{
    int id;
    int cnt=0;
    int car[5005];
}d[5005];
void check(int ca,int dis,int a,int vn){
    if(a==0){
        if(vn<=v)
            return;
        for(int i=1;i<=m;i++){
            if(d[i].id>=dis){
                t[ca]++;  //the car photoed
                d[i].car[++d[i].cnt]=ca; //record the car
            }
        }
    }else if(a<0){
        if(vn<=v)
                return;
        int v2=vn*vn-v*v;
        a=-a;
        int r=((v2)/2)/a;
        if(2*a*r==v2)
            r-=1;
        for(int i=1;i<=m;i++){
            if(d[i].id>=dis&&d[i].id<=dis+r){
                t[ca]++;  //the car photoed
                d[i].car[++d[i].cnt]=ca; //record the car
            }
        }
    }else{
        if(vn>v){
            for(int i=1;i<=m;i++){
                if(d[i].id>=dis){
                    t[ca]++;  //the car photoed
                    d[i].car[++d[i].cnt]=ca; //record the car
                }
            }
            return;
        }
        int v2=v*v-vn*vn;
        int l=(v2)/2/a;
        if(2*a*l==v2)
                l+=1;
        for(int i=1;i<=m;i++){
            if(d[i].id>=dis+l){
                t[ca]++;  //the car photoed
                d[i].car[++d[i].cnt]=ca; //record the car
            }
        }
    }
}
int check(){
    for(int i=1;i<=n;i++){
        if(vis[i]==0)
            continue;
        if(t[i]==0)
            return -1;
    }
    return 1;
}
int search_ans(int now,int ans){
    //cout<<now<<' '<<ans<<endl;
    if(now==m+1)
        return ans;
    if(d[now].cnt==0)
        return search_ans(now+1,ans+1);
    for(int i=1;i<=d[now].cnt;i++){
        t[d[now].car[i]]-=1;
    }
    if(check()==1){
          //  cout<<now<<endl;
            int ans2=search_ans(now+1,ans+1);
            for(int i=1;i<=d[now].cnt;i++){
                t[d[now].car[i]]+=1;
            }
            return max(ans2,search_ans(now+1,ans));

    }else{
         for(int i=1;i<=d[now].cnt;i++){
                t[d[now].car[i]]+=1;
            }
        return search_ans(now+1,ans);
    }

}
int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return x*f;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    scanf("%d",&T);
    while(T--){
        memset(t,0,sizeof(t));
        memset(vis,0,sizeof(vis));
      //  cin>>n>>m>>l>>v;
        n=read(),m=read(),l=read(),v=read();
        for(int i=1;i<=n;i++){
          //  cin>>c[i].x>>c[i].v>>c[i].a;
            c[i].x=read(),c[i].v=read(),c[i].a=read();
        }
        for(int i=1;i<=m;i++){
          //  cin>>d[i].id;
            d[i].id=read();
            d[i].cnt=0;
        }
        int cnt=0;
        for(int i=1;i<=n;i++){
            check(i,c[i].x,c[i].a,c[i].v);
            if(t[i]!=0){
                    cnt++;
                    vis[i]=1;
            }
          //  cout<<t[i]<<endl;
        }
        printf("%d ",cnt);
        printf("%d\n",search_ans(1,0));
    }
    return 0;
}
